<?php 
/**
* @author Oliver Leisalu, Inditel Meedia
* @package DomFg
* @subpackage Input
*/
class DomFgNumber extends DomFgTextField {
	
	protected $value;
	
	public function __construct( $name = NULL, $value = NULL ) {
		parent::__construct( $name );
		$this->value( $value );
	}
	
	public function render() {
		$renderer = $this->getRenderer();
		$renderer->assign('input', $this );
		return $renderer->fetch('Input/Number.html');
	}
	
	protected static function getReturnValue( $value ) {
		$value = str_replace(',','.',$value);
		if( is_array($value) ) {
			foreach( $value as &$v) {
				$v = self::getReturnValue( $v );
			}
			return $value;
		} else {
			return (float)$value;
		}
	}
	
	public static function parsePost( $name, &$value ) {
		return self::getReturnValue($value);
	}
	
	

}
?>